using DG.Tweening;
using UnityEngine;

namespace Share.UI
{
    //节点飞走
    public class UIEffect_NodeFly : UIEffectBase
    {

        [SerializeField]
        float m_Duration = 0.5f;
        [SerializeField]
        Vector2 m_MoveOffset = new Vector2(0, 0);
        // Start is called before the first frame update
        void Start()
        {
            //DoActionEnter();
        }

        // Update is called once per frame
        void Update()
        {

        }

        public override void OnActionEnter()
        {
            var rc = GetComponent<RectTransform>();
            Vector2 targetPos = rc.anchoredPosition;
            rc.anchoredPosition = targetPos;
            rc.DOAnchorPos(targetPos + m_MoveOffset, m_Duration).SetEase(Ease.InQuad);
        }

        public override void DoActionExit()
        {
            var rc = GetComponent<RectTransform>();
            Vector2 targetPos = rc.anchoredPosition + m_MoveOffset;
            rc.DOAnchorPos(targetPos, m_Duration).SetEase(Ease.InQuad);
        }
    }
}
